﻿// ------------------------------------------------------------------------------------------------
//  <copyright file="Shield.cs" company="Iveely">
//    Copyright (c) Iveely Liu.  All rights reserved.
//  </copyright>
//  
//  <Create Time>
//    03/02/2013 21:59 
//  </Create Time>
//  
//  <contact owner>
//    liufanping@iveely.com 
//  </contact owner>
//  -----------------------------------------------------------------------------------------------

#region

using IveelySE.Common;

#endregion

namespace IveelySE.Liquidate
{
    /// <summary>
    ///   禁用屏蔽处理
    /// </summary>
    public class Shield
    {
        /// <summary>
        ///   词汇集合
        /// </summary>
        public static SortedList<int> List = new SortedList<int>();

        /// <summary>
        ///   加载词汇
        /// </summary>
        public static void Load()
        {
            string[] words = {"的", "了", "地"};
            foreach(string word in words)
            {
                List.Add(Function.Hash(word));
            }
            //List.Sort();
        }

        /// <summary>
        ///   清理禁用词
        /// </summary>
        /// <param name="keys"> 分词后的关键字 </param>
        /// <returns> </returns>
        public static bool Process(string[] keys)
        {
            //禁用词是否存在,false不存在
            bool hasIT = false;
            foreach(string key in keys)
            {
                if(List.BinarySearch(Function.Hash(key)) > -1)
                {
                    hasIT = true;
                    break;
                }
            }
            return hasIT;
        }
    }
}